package com.data.migration.service;

import com.data.migration.util.DBUtil;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

/**
 * Created by Peter on 2018/12/11.
 */
public class Task {
    public static final Logger logger = LoggerFactory.getLogger(Task.class);

    public static void main(String[] args) {
        long start = System.nanoTime();
        try {
            Task task = new Task();
            task.startAll();
//        task.cleanAll();
        } catch (Exception e) {
            logger.error(e.getMessage(), e);
        } finally {
            long end = System.nanoTime();
            double duration = (end - start) / 1000000000.00;// 持续时长，秒
            logger.info("总耗时：" + DBUtil.nbf.format(duration) + "秒");
        }


    }

    public void startAll() throws Exception {
        // 第一步：更改表结构
        Step_0 step_0 = new Step_0();
        step_0.start();

        Step_1_Course step_1Course = new Step_1_Course();
        step_1Course.start();

        Step_2_Member step_2Member = new Step_2_Member();
        step_2Member.start();

        Step_3_Teacher step_3 = new Step_3_Teacher();
        step_3.start();

        Step_4_CourseComment step_4 = new Step_4_CourseComment();
        step_4.start();

        Step_5_Weike step_5 = new Step_5_Weike();
        step_5.start();

        Step_6_Member_Others step_6 = new Step_6_Member_Others();
        step_6.start();

        Step_7_Appointment step_7 =new Step_7_Appointment();
        step_7.start();

        Step_8_Teacher_Others step_8 = new Step_8_Teacher_Others();
        step_8.start();
    }

    public void cleanAll() throws Exception {
        Step_1_Course step_1Course = new Step_1_Course();
        step_1Course.clean();

        Step_2_Member step_2Member = new Step_2_Member();
        step_2Member.clean();

        Step_3_Teacher step_3 = new Step_3_Teacher();
        step_3.clean();

        Step_4_CourseComment step_4 = new Step_4_CourseComment();
        step_4.clean();

        Step_5_Weike step_5 = new Step_5_Weike();
        step_5.clean();

        Step_6_Member_Others step_6 = new Step_6_Member_Others();
        step_6.clean();

        Step_7_Appointment step_7 =new Step_7_Appointment();
        step_7.clean();

        Step_8_Teacher_Others step_8 = new Step_8_Teacher_Others();
        step_8.clean();

        // 最后清理表结构
        Step_0 step_0 = new Step_0();
        step_0.clean();

    }


}
